﻿@model IEnumerable<sBlog.Net.Domain.Entities.PostEntity>
@{
    if (Model.Any() != false)
    {
    <div class="titleControl">
        có thể bạn thích xem
    </div>
    }
}
<div class="relateTag">
    @{
        int i = 1;
    }
    @foreach (var post in Model)
    {
        var url = Url.RouteUrl("IndividualPost", new { year = post.PostYear, month = post.PostMonth, url = post.PostUrl, status = string.Empty });
        var shortTitle = post.PostTitle.Length > 60 ? string.Format("{0}...", post.PostTitle.Substring(0, 60)) : post.PostTitle;
        var avatar = string.Empty;
        if (post.PostAvatarSquare == string.Empty || post.PostAvatarSquare == null || post.PostAvatarSquare == "")
        {
            avatar = post.PostAvatar;
        }
        else
        {
            avatar = post.PostAvatarSquare;
        }

        if (i == 4)
        {
            i = 1;
        }
        if (i == 1)
        {
        <div class="itemFirst">
            @{
                <a href="@url" class="titleNewPost">
                    <img src="@Url.Content("http://s1.img.yan.vn/Mlog/UploadThumbs/196x196_" + @avatar)" style="border: none 0;" width="196" height="196" alt="user avatar"/></a>
                <br />
                <a href="@url" class="titleNewPost">
                    @shortTitle
                </a>
            }
        </div>
        }
        else if (i == 2)
        { 
        <div class="itemMiddle">
            @{
                <a href="@url" class="titleNewPost">
                    <img src="@Url.Content("http://s1.img.yan.vn/Mlog/UploadThumbs/196x196_" + @avatar)" style="border: none 0;" width="196" height="196" alt="user avatar"/>
                </a>
                <br />
                <a href="@url" class="titleNewPost">
                    @shortTitle
                </a>
            }
        </div>
        }
        else if (i == 3)
        { 
        <div class="itemLast">
            @{
                <a href="@url" class="titleNewPost">
                    <img src="@Url.Content("http://s1.img.yan.vn/Mlog/UploadThumbs/196x196_" + @avatar)" style="border: none 0;" width="196" height="196" alt="user avatar"/>
                </a>
                <br />
                <a href="@url" class="titleNewPost">
                    @shortTitle
                </a>
            }
        </div>
        }
        i++;
    }
</div>
